﻿@using Media.Core.Helpers.Main;
@using Media.Core.Helpers.Movies;
@model Media.Core.Models.MovieArray
@{
    ViewBag.Title = "Index";
}

<script type="text/javascript">
    $("#MovieNav").addClass("current");
</script>


<link rel="stylesheet" href="@Url.Content("~/Content/Peach/css/sprite.tables.css")"> <!-- SPRITE: Tables styling -->
<script type="text/javascript">

    function SelectMovie (Id) {
        $(document).ready(function () {
            window.location = '@Url.Content("~/Movie/Details/")' + Id;
        });
    }


    function insertmovie() {
        document.getElementById('LoadingGif').style.display = 'inline-block';
        $.getJSON('@Url.Content("~/Movie/UpdateMovieList")',
        function (data) {
            alert("Success");
            document.getElementById('LoadingGif').style.display = 'none';
        });
    }

</script>

<h2 style="display:inline-block;">Movie List</h2>
<img id="LoadingGif" src="../../Content/images/loadera64.gif" style="width:20px;height:20px;display:none;"/><br />

<div style="float:right;margin-right:20px;">
    <b>Current Movie Directory:</b>
    @GetDirectory.Location("Movies")
</div>
@*<button onclick="location.href='/Movie/Create'">Add Movie</button>*@
<button onclick="insertmovie();">Update Movie List</button>



@*<div style="height: 600px; overflow:scroll;width:100%; overflow-x:hidden"">

<table class="features-table">
    <thead>
        <tr>
            <td></td>
            <td style="text-align:center;">Year</td>
            <td style="text-align:center;">Quality</td>
            <td style="text-align:center;">Rating</td>
            <td style="text-align:center;">Options</td>
        </tr>
    </thead>
    <tfoot>
        <tr>
            <td>@("Total Movies: " + Model.Movies.Count)</td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
    </tfoot>
    <tbody>
            @foreach (var Movie in Model.Movies)
            {
                <tr onclick="SelectMovie(@Movie.Id);">
                    <td>
                        @Html.Raw(Movie.Title)
                    </td>
                    <td style="text-align: center;">
                        @Movie.Year
                    </td>
                    <td style="text-align: center;">
                        @Movie.Quality
                    </td>
                    <td style="text-align: center;">
                        @Movie.Rating
                    </td>
                    <td>
                        @Html.ActionLink("Edit", "Edit", new { id = Movie.Id }) |
                        @Html.ActionLink("Details", "Details", new { id = Movie.Id }) |
                        @Html.ActionLink("Remove", "Remove", new { id = Movie.Id })
                    </td>
                </tr>
            }
    </tbody>
</table>

</div>*@

			

<div class="box">
	<div class="header">
		<img src="@Url.Content("~/Content/Peach/img/icons/packs/fugue/16x16/shadeless/table.png")" width="16" height="16" />
		<h3>Movies</h3><span></span>
	</div>
	<div class="content no-padding">
		<table class="table">
			<thead>
				<tr>
					<th scope="col">Movie</th>
					<th scope="col">Year</th>
					<th scope="col">Quality</th>
					<th scope="col">Rating</th>
					<th scope="col">Options</th>
				</tr>
			</thead>
            <tfoot>
                <tr>
                    <td>@("Total Movies: " + Model.Movies.Count)</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
            </tfoot>
			<tbody>
                @foreach (var Movie in Model.Movies)
                {
                    <tr onclick="SelectMovie(@Movie.Id);">
                        <td>
                            @Html.Raw(Movie.Title)
                        </td>
                        <td style="text-align: center;">
                            @Movie.Year
                        </td>
                        <td style="text-align: center;">
                            @Movie.Quality
                        </td>
                        <td style="text-align: center;">
                            @Movie.Rating
                        </td>
                        <td>
                            @Html.ActionLink("Edit", "Edit", new { id = Movie.Id }) |
                            @Html.ActionLink("Details", "Details", new { id = Movie.Id }) |
                            @Html.ActionLink("Remove", "Remove", new { id = Movie.Id })
                        </td>
                    </tr>
                }
        </tbody>
		</table>
	</div> <!-- End of .content -->
	<div class="clear"></div>
</div> <!-- End of .box -->